var hasCycle = function (head) {
  let cur = head
  while(cur) {
    if (cur.flag) {
      return true
    } else {
      cur.flag = true
      cur = cur.next
    }
  }
  return false
};